package hust.rpc.utils;

import hust.rpc.pojo.Host;
import io.netty.channel.Channel;

import java.net.InetSocketAddress;

public class CommonUtils {

    public static Host channelToHost(Channel channel) {
        InetSocketAddress socketAddress = (InetSocketAddress) channel.remoteAddress();
        return new Host(socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
    }

    public static String getFutureKey(Host host, Long id) {
        return host.getIp() + ':' + host.getPort() + ':' + id;
    }
}
